﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace PlaceOrder_Shared.Models.Trade
{
    public class UINotifyPropertyChanged : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged([CallerMemberName] string propertyName = "")
        {

            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler.Invoke(this, new PropertyChangedEventArgs(propertyName));
            }

        }
    }
    public class TradeHistoryRow: UINotifyPropertyChanged
    {

        public TradeHistoryRow()
        {

        }
        public TradeHistoryRow(TradeHistoryRow thr)
        {
            TsCode = thr.TsCode;
            TradeDate = thr.TradeDate;
            TradeTime = thr.TradeTime;
            TradePrice = thr.TradePrice;
            DealType = thr.DealType;
            BrokerID = thr.BrokerID;
            BrokerName = thr.BrokerName;
            Date = thr.Date;
            Volume = thr.Volume;
            Valid = thr.Valid;
            NetPrice = thr.NetPrice;
            Forward = thr.Forward;
            TradeID = thr.TradeID;
            Withdraw = thr.Withdraw;
            PriceDiffName = thr.PriceDiffName;
        }
        public Int64 id { get; set; }

        /// <summary>
        /// 证券代码
        /// </summary>
        public string TsCode { get; set; } = "";

        /// <summary>
        /// 交易日期
        /// </summary>
        public DateTime TradeDate { get; set; }

        /// <summary>
        /// 交易时间
        /// </summary>
        public string TradeTime { get; set; } = "";

        /// <summary>
        /// 交易价格
        /// </summary>
        public decimal TradePrice { get; set; } = 0M;

        /// <summary>
        /// 交易类型（买入/卖出）
        /// </summary>
        public string DealType { get; set; } = "";

        /// <summary>
        /// 经纪人ID
        /// </summary>
        public int BrokerID { get; set; } = 0;

        /// <summary>
        /// 经纪人名称
        /// </summary>
        public string BrokerName { get; set; } = "";


        public DateOnly Date { get; set; }

        /// <summary>
        /// 交易量
        /// </summary>
        public int Volume { get; set; }

        /// <summary>
        /// 交易是否有效
        /// </summary>
        public bool Valid { get; set; } = true;


        /// <summary>
        /// 净价
        /// </summary>
        public decimal NetPrice { get; set; }

        /// <summary>
        /// 是否正向交易
        /// </summary>
        public bool Forward { get; set; }

        /// <summary>
        /// 交易ID
        /// </summary>
        public string TradeID { get; set; } = "";

        /// <summary>
        /// 是否已经撤销（或者提取）了某笔交易
        /// </summary>
        public bool Withdraw { get; set; }

        /// <summary>
        /// 价格差异
        /// </summary>
        public string PriceDiffName { get; set; } = "";

        /// <summary>
        /// 交易是否已处理
        /// </summary>
        public bool Handled { get; set; }

        /// <summary>
        /// 清算速度
        /// </summary>
        private string settleSpeed;

        public string SettleSpeed
        {
            get { return settleSpeed; }
            set { settleSpeed = value; OnPropertyChanged("SettleSpeed"); }
        }

     
    }
}
